home *** CD-ROM | disk | FTP | other *** search
Makefile | 1994-09-14 | 6.0 KB | 199 lines | [TEXT/R*ch] |
- # Universal Makefile to build Python extensions.
- #
- # Instructions:
- #
- # 0) Build and install the basic Python 1.0.2 distribution. You must
- # also install the headers ("make inclinstall") and the binary library
- # files ("make libainstall").
- #
- # 1) Edit Makefile.pre.in (not any other file!!!) to change the
- # definition of installdir (and possibly exec_installdir). These
- # should match the prefix and exec_prefix used when installing Python.
- # Alternatively, you can specify a value for installdir on the
- # "make -f Makefile.pre.in Makefile" command line (see below). This
- # is probably easier since it avoids editing Makefile.pre.in at all...
- #
- # 2) Copy Setup.in to Setup and edit Setup to change the selection of
- # modules you want to use. Read the comments in the core Python's
- # Modules/Setup.in for more detailed instructions.
- #
- # 3) Run "make Makefile -f Makefile.pre.in". This creates Makefile
- # (producing Makefile.pre and sedscript as intermediate files) and
- # config.c. Values for installdir, srcdir, VPATH, LINKPATH, OPT,
- # BASELIB and BASESETUP on the make command line will be incorporated
- # in the final Makefile.
- #
- # 4) Run "make". This creates a Python executable. The set of
- # built-in modules and features is a superset of that of the basic
- # Python -- additions are taken from ./Setup.
- #
- # If you don't actually want to install the Python headers and
- # binary library files, you can edit the "Fixed definitions" section
- # below to point directly into the source and/or build tree.
- #
- # Note: Each time you edit Makefile.pre.in or Setup, you must run
- # "make Makefile" before running "make".
- #
- # Hint: if you want to use VPATH, you can start in an empty
- # subdirectory and say (e.g.):
- # make -f ../Makefile.pre.in srcdir=.. VPATH=.. Makefile
-
-
- # === Variables that you just *have* to customize manually ===
-
- # (You can also specify their values on the command line for
- # "make -f Makefile.pre.in Makefile".)
-
- # The prefix used by "make inclinstall libainstall" of core python
- installdir= /usr/local
-
- # The exec_prefix used by the same
- exec_installdir=$(installdir)
-
- # Source directory and VPATH in case you want to use VPATH.
- # (You will have to edit these two lines yourself -- there is no
- # automatic support as the Makefile is not generated by
- # config.status.)
- srcdir= .
- VPATH= .
-
- # === Variables that you may want to customize ===
-
- # Add possible -L options here
- LINKPATH=
-
- # You may want to change this to -O
- OPT= -g
-
- # Add more -I and -D options here
- CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(LIBPL) $(DEFS)
-
- # These two variables can be set in Setup to merge extensions.
- # See example[23].
- BASELIB=
- BASESETUP=
-
- # === Variables set by makesetup ===
-
- MODOBJS= @MODOBJS@
- MODLIBS= @MODLIBS@
-
- # === Definitions added by makesetup ===
-
- # === Variables from configure (through sedscript) ===
-
- CC= @CC@
- DEFS= @DEFS@
- LIBS= @LIBS@
- LIBM= @LIBM@
- LIBC= @LIBC@
- RANLIB= @RANLIB@
- MACHDEP= @MACHDEP@
- SO= @SO@
- LDSHARED= @LDSHARED@
- CCSHARED= @CCSHARED@
- LINKFORSHARED= @LINKFORSHARED@
-
- # Install prefix for architecture-independent files
- prefix= /usr/local
-
- # Install prefix for architecture-dependent files
- exec_prefix= $(prefix)
-
- # === Fixed definitions ===
-
- INCLUDEPY= $(installdir)/include/Py
- LIBP= $(exec_installdir)/lib/python
- LIBPL= $(LIBP)/lib
-
- PYTHONLIBS= $(LIBPL)/libModules.a \
- $(LIBPL)/libPython.a \
- $(LIBPL)/libObjects.a \
- $(LIBPL)/libParser.a
-
- MAKESETUP= $(LIBPL)/makesetup
- MAKEFILE= $(LIBPL)/Makefile
- CONFIGC= $(LIBPL)/config.c
- CONFIGCIN= $(LIBPL)/config.c.in
- SETUP= $(LIBPL)/Setup
-
- SYSLIBS= $(LIBM) $(LIBC)
-
- # === Fixed rules ===
-
- all: python
-
- sharedmods: $(SHAREDMODS)
-
- python: config.o lib.a $(PYTHONLIBS) Makefile
- $(CC) config.o lib.a $(PYTHONLIBS) \
- $(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python
-
- lib.a: $(MODOBJS)
- -rm -f lib.a
- ar cr lib.a $(MODOBJS)
- -$(RANLIB) lib.a || \
- echo "don't worry if ranlib fails -- probably SYSV or equiv"
-
- # This runs makesetup *twice* to use the BASESETUP definition from Setup
- config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
- $(MAKESETUP) \
- -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
- $(MAKE) -f Makefile do-it-again
-
- do-it-again:
- $(MAKESETUP) \
- -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
-
- config.o: config.c Makefile
- $(CC) $(CFLAGS) -DPYTHONPATH=\"$(PYTHONPATH)\" -c config.c
-
- # Setup is copied from Setup.in *only* if it doesn't yet exist
- Setup:
- cp $(srcdir)/Setup.in Setup
-
- Makefile.pre: Makefile.pre.in sedscript
- sed -f sedscript $(srcdir)/Makefile.pre.in >Makefile.pre
-
- # Shortcuts to make the sed arguments on one line
- P=prefix
- E=exec_prefix
- H=Generated automatically from Makefile.pre.in by sedscript.
- sedscript: $(MAKEFILE)
- sed -n \
- -e '1s/.*/1i\\/p' \
- -e '2s%.*%# $H%p' \
- -e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
- -e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
- -e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
- -e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
- -e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
- -e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
- -e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
- -e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
- -e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
- -e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
- -e '/^LINKFORSHARED=/s/^LINKFORSHARED=[ ]*\(.*\)/s%@LINKFORSHARED[@]%\1%/p' \
- -e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
- -e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
- $(MAKEFILE) >sedscript
- ( \
- echo "/^installdir=/s%=.*%= $(installdir)%"; \
- echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%"; \
- echo "/^srcdir=/s%=.*%= $(srcdir)%"; \
- echo "/^VPATH=/s%=.*%= $(VPATH)%"; \
- echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%"; \
- echo "/^OPT=/s%=.*%= $(OPT)%"; \
- echo "/^BASELIB=/s%=.*%= $(BASELIB)%"; \
- echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%"; \
- ) >>sedscript
-
- clean:
- -rm -f *.o *~
-
- clobber: clean
- -rm -f python lib.a sedscript config.c Makefile.pre
-
- distclean: clobber
- -rm -f Makefile Setup
-